﻿@{
    ViewBag.Title = "show2";
    Layout = null;
}

<div id="cphMain_ctl00_ContentPane" class="center">
    <div id="Breadcrumb" class="Breadcrumb">
    <ul>
        <li class="first">
            <a href='javascript:;' onclick="javascript:loadShow('main','')">
                Trang chủ
            </a>
        </li>
        
                
            @if (Request.QueryString["id"]==null || Request.QueryString["id"].Length == 0
                || Convert.ToInt32(Request.QueryString["id"]) == 0)
            {
                <li>
                    <span>Sản phẩm</span>
                </li>                
            }
            else if (Request.QueryString["group"] == null || Request.QueryString["group"].Length == 0)
            {
                <li>
                    <a href='javascript:;' onclick="javascript:loadShow('','')">Sản phẩm</a>
                </li>
                <li>
                    <span>@ViewBag.cateName</span>
                </li>                   
            }else
            {
                <li>
                    <a href='javascript:;' onclick="javascript:loadShow('','')">Sản phẩm</a>
                </li>
                <li>
                    <a href='javascript:;' onclick="javascript:loadShow(@ViewBag.id,'')">@ViewBag.cateName</a>
                </li> 
                  <li>
                    <span>@Request.QueryString["group"]</span>
                </li>
            }
             
            
    </ul>
</div>
    <div class="Clear"></div>
    <style type="text/css">
.InfoMessage{ background: #EFF8FA; color: #555555; margin-bottom: 10px; padding: 6px; padding-bottom: 1px; }
.InfoMessage p{ line-height: 1.3; margin-bottom: 15px; }
.listing-type-list .disable{ display: none; }
</style>
    
    

    <div class="ProductListContainer ListItems DefaultModule">
    <div class="category-title defaultTitle productlist-title">
        @if (Request.QueryString["id"] == null || Request.QueryString["id"].Length == 0
            || Convert.ToInt32(Request.QueryString["id"]) == 0)
        {
            <h1>Sản Phẩm</h1>
        }
        else if (Request.QueryString["group"] == null || Request.QueryString["group"].Length==0)
        {
            <h1>@ViewBag.cateName</h1>
        }
        else
        {
            <h1>@Request.QueryString["group"]</h1>
        }
        
    </div>
    <div class="TopContent">
        
    </div>
    <div id="ProductList" class="defaultContent listing-type-list productlist-content catalog-listing">
        
     @{int count = Enumerable.Count(ViewBag.list);
       string first = "First";
       for (int i = 0; i < ((count - 1) / 4 + 1); i++)
       {
           if (i > 0)
           {
               first = "";
           }
                    <ul class="ProductList @first">                    
                        @{ string old_even;
                           for (int j = i * 4; j < (i + 1) * 4 && j < count; j++)
                           {
                               var pro = Enumerable.ElementAt(ViewBag.list, j);
                               if (j % 2 == 0)
                               {
                                   old_even = "Odd";
                               }
                               else
                               {
                                   old_even = "Even";
                               }
                        <li class="@old_even">
                                <div id="ProductImage" class="ProductImage ProductImageTooltip po_190309">
                                    <a href="javascript:;" onclick="javascript:viewProduct(@pro.ID)" rel="2172035" class="#tooltip2172035"
                                        productname='@pro.name' quantity='@pro.amount @pro.type / thùng'
                                        thumbnail='/Content/data/images/350.300/@pro.image_link' 
                                        thumbnailerror='/Content/data/images/not_available.jpg' volume='@pro.volume' >
                                        <img alt="@pro.name" title="@pro.name" 
                                                src="/Content/data/images/350.300/@pro.image_link" height="120"
                                            onerror="/Content/data/images/not_available.jpg" />
                                    </a>
                                </div>
                            @if (pro.promotion_ID > 0)
                            {
                                <div class="saleFlag iconSprite ">
                                    @pro.Promotion.rate<span>%</span></div>
                            }                                
                                <div class="ProductDetails">
                                    <strong><a href=href="javascript:;" onclick="javascript:viewProduct(@pro.ID)">
                                        @pro.name<span class='Flag-Promotion'>&nbsp;</span></a></strong>
                                </div>
                                <div class="ProductPrice">
                                    @{ string retail_price = pro.price.ToString("0,0") + "VND / thùng";
                                       decimal sale_price = pro.price;
                                       if (pro.promotion_ID > 0)
                                       {
                                           sale_price = pro.price / 100 * (100 - pro.Promotion.rate);
                                       }
                                       else
                                       {
                                           retail_price = "";
                                       }
                                       
                                        <div class="retail-price ">                                        
                                        <span class="price-label"></span><span class="price">
                                            &nbsp;<strike class="RetailPriceValue">                                            
                                            @retail_price
                                            </strike>
                                        </span>                                        
                                    </div>
                                    <div class="special-price">
                                        <span class="price-label"></span><span class="price"><em>
                                            @sale_price.ToString("0,0") VND / thùng</em>
                                        </span>
                                    </div>
                                    }
                                </div>

                                <div class="ProductActionAdd">
                                    <a href="javascript:;" onclick="javascript:addWishlist(@pro.ID,'@Session["username"]')"><span>Thích</span></a>
                                    <a href="javascript:;" onclick="javascript:addProToCart(@pro.ID,1)"><span>Mua hàng</span></a>
                                </div>
                            </li>                                               
                           }
                    <br class="Clear" />
                        }
                </ul>         
                
     }  
     }    
            
        
        <div class="clear">
        </div>                
        
        <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
            @{var previousPage = Math.Max(ViewBag.currentPage-1, 1);}
            <a  href="javascript:;" onclick="javascript:loadActionData('show2','Main','pageNum=@previousPage&group=@ViewBag.group_name&id=@ViewBag.id')">&lt;&lt;</a>    
            @for(int num = 1; num <= ViewBag.maxPage; num ++)
            {
               if(ViewBag.currentPage == num)
               {
                  <a class="active" href="#" 
                      style="background-color:gray;color:white;"><strong>@num</strong></a>
                }
                else
                {
                   <a  href="javascript:;" onclick="javascript:loadActionData('show2','Main','pageNum=@num&group=@ViewBag.group_name&id=@ViewBag.id')">@num</a>    
                }
            }                   
            @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
            <a href="javascript:;" onclick="javascript:loadActionData('show2','Main','pageNum=@nextPage&group=@ViewBag.group_name&id=@ViewBag.id')">&gt;&gt;</a>    
        </div>

    </div>
    <div class="clear defaultFooter productlist-footer">
        <div>
        </div>
    </div>
</div>




<div id="productReviewPopup190309" class="hidden"></div>
<script type="text/javascript">
    $j(function () {
        $j(".ProductList .po_190309 a").each(function () {
            var productname = $j(this).attr("productname");
            var thumbnail = $j(this).attr("thumbnail");
            var thumbnailerror = $j(this).attr("thumbnailerror");
            var quantity = $j(this).attr("quantity");
            var volume = $j(this).attr("volume");
            $j(this).bind("mouseover", function () {                
                var returnHtml =
                    "<div class=\"tooltip_name\">" + productname + '</div>' +
                    "<div class=\"tooltip_picture\">" +
                        "<img src=\"" + thumbnail + "\" onerror=\"this.src='" + thumbnailerror + "'\" title=\"" + productname
                        + "\" alt=\"" + productname + "\" height=\"250\"/></div>" +
                    "<div class=\"tooltip_description\">Số lượng: " + quantity + "</div>" +
                    "<div class=\"tooltip_description\">Thể tích: " + volume + " ml</div>"
                $j("#productReviewPopup190309").html(returnHtml);
            });
            $j(this).tooltip({
                track: true, delay: 50, showURL: false,
                bodyHandler: function () {
                    return $j("#productReviewPopup190309").html();
                }
            });
        });
    });
</script>

</div>

